package cate.game.pvp.pointrace.data;

import cate.game.db.mongo.kv.KvMongo;
import cate.game.framework.advanced.AdvancedLongAttributes;
import cate.game.framework.advanced.AdvancedModuleKV;
import cate.game.pvp.pointrace.support.PointRaceGMSupport;
import cate.game.pvp.pointrace.timer.PointRaceTimerTask.Settings;
import cate.game.role.pvp.PvpRecord;
import easy.java.dev.note.NoteField;
import lombok.Data;
import lombok.ToString;

import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;

import static cate.common.table.d.GDPointRace.NEW_BEE_RECORD_NUM;

@ToString
@Data
public class PointRaceKV extends AdvancedModuleKV {
    @NoteField(value = "赛季")
    private int season;
    @NoteField(value = "整个赛季时间long")
    private long cycleTimeMs;
    @NoteField(value = "当前第几天")
    private int day;

    private List<Settings> timerSettings;

    public CopyOnWriteArrayList<PvpRecord> records;

    private PointRacePsData psData;

    private PointRaceRankData rankData;

    private Map<Integer, Map<String, Integer>> dailyRankRd;

    private AdvancedLongAttributes eventAttributes;

    private PointRaceGMSupport gmSupport;

    @Override
    public String getKeyPrefix() {
        return KvMongo.KEY_POINT_RACE;
    }

    public void addRecord(PvpRecord record) {
        if (records.size() > NEW_BEE_RECORD_NUM) {
            records.remove(0);
        }
        records.add(record);
    }

}
